package com.getway.controller.uploadcontroller;

import com.common.contant.RestResponse;
import com.getway.client.UploadClient;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author: sijunqiang
 * @Date: 2020/5/27 18:06
 * @Description: 图片上传控制层
 */
@RestController
@Slf4j
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@RequestMapping(value = "/image")
public class UploadController {

    private final UploadClient uploadClient;

    /**
     * 上传图片
     *
     * @param file 图片的文件
     * @return 请求的地址
     */
    @PostMapping(value = "/image")
    public RestResponse uploadImage(@RequestParam(value = "file") MultipartFile file) {
        log.info(">>>>>>>>>开始调用upload-service服务进行上传图片>>>>>>>");
        return RestResponse.success(uploadClient.uploadImage(file));
    }





}
